package Lab12;

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.Scanner;

public class test4 {
    public static void main(String[] args) throws IOException {
        try {
            URL url=new URL("https://www.douban.com/robots.txt");
            URLConnection connection = url.openConnection();
            connection.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)");
            Scanner in = new Scanner(connection.getInputStream());
            int word=0;
            while (in.hasNextLine())
            {
                String str=in.nextLine();
                String[] xx=str.split("\\s+");
                int a1=xx.length;
                word=word+a1;
            }
            System.out.println(word);
//            68
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }
        catch (IOException ex)
        {
            System.out.println("dsadas");
        }
    }
}